Skip to content

Update telemetry event dependency to OpenTelemetry LoggingHandler#69

Merged
yuanqu72 merged 13 commits into
microsoft:mainfrom
yuanqu72:yuanqu-telemetry
Jun 30, 2026
Merged

Update telemetry event dependency to OpenTelemetry LoggingHandler#69
yuanqu72 merged 13 commits into
microsoft:mainfrom
yuanqu72:yuanqu-telemetry

Conversation

@yuanqu72

@yuanqu72 yuanqu72 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Overview
This pull request modernizes the Azure Monitor telemetry integration by switching from the deprecated azure-monitor-events-extension to the OpenTelemetry logging handler. It updates the telemetry event sending logic, improves the handling of reserved log attributes, and refactors tests to match the new implementation. Dependency management and sample requirements are also updated for consistency.

Telemetry integration updates:

  • Replaces usage of azure-monitor-events-extension with OpenTelemetry's LoggingHandler for sending telemetry events, introducing a dedicated logger (_event_logger) and initialization logic in _send_telemetry.py. This ensures telemetry events are sent in a more standard and extensible way.
  • Updates the track_event and publish_telemetry functions to use the new logging-based approach, including logic to avoid conflicts with reserved log record attributes. [1] [2]
  • Updates the TargetingSpanProcessor to check for OpenTelemetry logging support rather than the old extension.

Dependency and configuration changes:

  • Updates the optional Azure Monitor dependency in pyproject.toml to require opentelemetry-sdk instead of azure-monitor-events-extension.
  • Removes azure-monitor-events-extension from samples/requirements.txt.

Testing improvements:

  • Refactors tests in test_send_telemetry_appinsights.py to patch the new track_event function instead of the old event extension, and adds a helper to extract event properties from mock calls. [1] [2] [3] [4] [5] [6] [7]
  • Adds a new test to verify that reserved log record attributes (like microsoft.custom_event.name) are handled safely and not overwritten.

Validation

pip install -e C:\Users\yuanqu\workplace\FeatureManagement-Python

Verified that quota-of-the-day app is still able to send telemetry to my testing app insights in the correct location.
image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the Azure Monitor telemetry integration to emit feature evaluation events via OpenTelemetry’s LoggingHandler rather than the deprecated azure-monitor-events-extension, and updates the test suite and dependency metadata to align with the new approach.

Changes:

  • Replaced direct azure-monitor-events-extension event tracking with an OpenTelemetry-backed event logger in featuremanagement/azuremonitor/_send_telemetry.py.
  • Updated tests/test_send_telemetry_appinsights.py to assert the new track_event(event_name, user, event_properties=...) call shape and added coverage for the reserved microsoft.custom_event.name attribute behavior.
  • Updated pyproject.toml optional dependencies to use azure-monitor-opentelemetry and introduced an explicit OpenTelemetry logging instrumentation dependency (currently only in dev).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
featuremanagement/azuremonitor/_send_telemetry.py Refactors telemetry publishing to use an OpenTelemetry logging handler and updates span processor gating/types accordingly.
tests/test_send_telemetry_appinsights.py Adjusts tests to patch/assert the new tracking mechanism and validates reserved attribute handling.
pyproject.toml Swaps the Azure Monitor optional dependency to azure-monitor-opentelemetry and updates dev/test dependency lists.

Comment thread featuremanagement/azuremonitor/_send_telemetry.py
Comment thread pyproject.toml Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread featuremanagement/azuremonitor/_send_telemetry.py
Comment thread featuremanagement/azuremonitor/_send_telemetry.py
Comment thread tests/test_send_telemetry_appinsights.py
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread tests/test_send_telemetry_appinsights.py Outdated
Comment thread pyproject.toml Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread featuremanagement/azuremonitor/_send_telemetry.py Outdated
Comment thread tests/test_send_telemetry_appinsights.py Outdated
@yuanqu72 yuanqu72 merged commit 83fc1ad into microsoft:main Jun 30, 2026
6 checks passed
@yuanqu72 yuanqu72 deleted the yuanqu-telemetry branch June 30, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants